package com.hc.cosmetichospital.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hc.cosmetichospital.mapper.ClientsMapper;
import com.hc.cosmetichospital.pojo.Clients;
import com.hc.cosmetichospital.pojo.ResultMap;
import com.hc.cosmetichospital.service.ClientsService;
import com.hc.cosmetichospital.vo.ClientsVo;
import com.hc.cosmetichospital.vo.ConsultingVo;

@Service
public class ClientsServiceImpl implements ClientsService {

	@Autowired
	private ClientsMapper clientsMapper;
	
	@Override
	public ResultMap<Clients> getClientsList(ClientsVo clientsVo) {
		PageHelper.startPage(clientsVo.getPage(), clientsVo.getLimit());
		
		List<Clients> clientsList = clientsMapper.getClientsList(clientsVo);
		
		PageInfo<Clients> info = new PageInfo<Clients>(clientsList);
		
		return new ResultMap<Clients>(clientsList,(int)info.getTotal());
	}

	@Override
	public int addClients(ConsultingVo consultingVo) {
		return clientsMapper.insertSelective(consultingVo);
	}

	@Override
	public List<Clients> getClientsSelect() {
		return clientsMapper.clientsSelect();
	}

	@Override
	public int deleteClients(Integer id) {
		return clientsMapper.deleteByPrimaryKey(id);
	}

}
